﻿using System;
using System.Collections.Generic;
using Mbs.ComponentModel.Container.Activation;
using Mbs.ComponentModel.Container.Injection;
using Mbs.ComponentModel.Container.Lifestyle;
using Mbs.ComponentModel.Container.Listner;
using Mbs.ComponentModel.Container.Loader;
using Mbs.ComponentModel.Container.Metadata;

namespace Mbs.ComponentModel.Container
{
    public interface IKernel : IMicroKernel
    {
        IKernelListnerManager ListnerManager { get; }
        ILoaderManager LoaderManager { get; }
        ILifestyleManagerFactory LifestyleManagerFactory { get; }
        IInjectStrategyManager InjectStrategyManager { get; }
        IActivatorFactory ActivatorFactory { get; }

        bool HasRegister(Type service);
        bool HasRegister(string id);

        IComponentInfo GetComponent(string id);

        object[] GetAll(Type service);
        T[] GetAll<T>();

        /// <summary>
        /// 得到服务
        /// </summary>
        /// <param name="id">服务Id</param>
        /// <returns>返回服务实例</returns>
        object Get(string id, IDictionary<string,object> args);

        /// <summary>
        /// 得到服务
        /// </summary>
        /// <param name="service">服务类型</param>
        /// <returns>返回服务实例</returns>
        object Get(Type serviceType, IDictionary<string,object> args);

        object Get(string id, params object[] args);
        object Get(Type serviceType, params object[] args);

       

       
        /// <summary>
        /// 注销服务
        /// </summary>
        /// <param name="id">服务</param>
        void UnRegister(Type service);

       


    }

    public static partial class KenelExtensions
    {
        public static bool HasRegister<TService>(this IKernel kernel)
        {
            return kernel.HasRegister(typeof(TService));
        }

       
    }
}
